package com.wu24.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.wu24.bean.Trolley;
public class TrolleyHandler extends HttpServlet {
	private static final long serialVersionUID = 1L;
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		      request.setCharacterEncoding("utf-8");
              Trolley trolley=(Trolley)request.getSession().getAttribute("trolley");
              String id=request.getParameter("id");   
              String type=request.getParameter("type");
              if(type.equals("add")){
              trolley.addGood(id);  
              }
              else if(type.equals("delete")){
            	  trolley.deleteGood(id);
              }
    		  request.getRequestDispatcher("cart.jsp").forward(request,response);                     
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
       this.doGet(request, response);
		
	}

	
}
